package com.aaa.java13;

import java.util.Objects;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/16 15:47
 * @description：
 * @modified By：
 * @version:
 */
public class MyPerson {
    /**
     * 标识符，唯一，跟数据库一一对应
     */
    private  int id;
    private  String name;
    private int age;


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public MyPerson() {
    }

    public MyPerson(int id, String name, int age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: 重写之后的equals方法
     * @create time: 2022/7/16 15:56
     * @param o
     * @return
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MyPerson myPerson = (MyPerson) o;
        return id == myPerson.id;
    }
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description: 重写之后的hashcode方法
     * @create time: 2022/7/16 15:56
     * @param
     * @return int
     */
    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    @Override
    public String toString() {
        return "MyPerson{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
